package com.nipun.facet.rmi;

import java.rmi.Naming;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;

import com.nipun.facet.neural.FacetNetworkRunner;
import com.nipun.facet.neural.FacetnetworkRunnerImpl;
import com.nipun.neural.utils.MultiLayeredFBNetworkCreator;

public class RegisterService {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String name = "//localhost/NeuralService";
        int xSize = 16;
		int ySize = 12;
		int[] layers = {100, 50, 10};
		MultiLayeredFBNetworkCreator netCreator = new MultiLayeredFBNetworkCreator(xSize*ySize, layers, "Sigmoid", "facetNet.xml");
		FacetNetworkRunner runner = new FacetnetworkRunnerImpl(netCreator.getNet(), xSize, ySize);
		if (System.getSecurityManager() == null) {
            System.setSecurityManager(new SecurityManager());
        }
        try {
            FacetNetworkRunner stub =
                (FacetNetworkRunner) UnicastRemoteObject.exportObject(runner, 0);
            Registry registry = LocateRegistry.createRegistry(1099);
            registry.rebind(name, stub);
            Naming.rebind(name , stub);
            System.out.println("Neural Engine bound");
        } catch (Exception e) {
            System.err.println("exception:");
            e.printStackTrace();
        }
    }

}
